package com.xianniu.ltc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.rebuild.core.UserContextHolder;
import com.xianniu.ltc.mapper.TXnIconConfigMapper;
import com.xianniu.ltc.model.entity.TXnIconConfigDTO;
import com.xianniu.ltc.service.XnIconConfigService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @author WangRuiJie
 * @Title: XnIconConfigServiceimpl
 * @Package com.xianniu.ltc.service.impl
 * @Description:
 * @date 2021/8/137:58 下午
 */
@Service
public class XnIconConfigServiceImpl implements XnIconConfigService {

    @Resource
    private TXnIconConfigMapper mapper;
    @Override
    public String selectIconByCode(String entityCode, String tenantCode) {
        UserContextHolder.setTenant(tenantCode);
        QueryWrapper<TXnIconConfigDTO> wrapper = new QueryWrapper<>();
        wrapper.eq("entity_code", entityCode);
        wrapper.eq("tenant_code", tenantCode);
        TXnIconConfigDTO dto =  mapper.selectOne(wrapper);
        return Objects.isNull(dto)?"https://xianniu-image.oss-cn-beijing.aliyuncs.com/h5_image/pms_pc/worker.png":dto.getIcon();
    }
}
